﻿module Sustainalytics.GCCS {

    import Common = Sustainalytics.Common;

    export class GCCompanyPrincipleController {

        // currently displayed view (Analysis of Issue, Analysis of Company Management, Assessment Summary and Conclusions)
        public detailsView: string;

        // current company principle
        public companyPrinciple: GCPrincipleSummaryDto;

        // whether to show principle details
        public showDetails: boolean;


        constructor(
            public $scope: ng.IScope,
            private $q: ng.IQService,
            public NumberUtilityService: Common.NumberUtilityService) {

            var ctx = this;
            $scope['gcCompanyPrinciple'] = ctx;

            // initially the details are hidden
            ctx.showDetails = false;

            // initial details view is not set
            ctx.detailsView = null;
        }

        // toggle whether to show principle details or not
        public toggleDetails() {
            this.showDetails = !this.showDetails;

            // when expanding Analysis of Issue is the default one
            if (this.showDetails) {
                this.showDetailsView(GCCompanyPrincipleViews.AnalysisOfIssue);
            }

            // if details view is not set then set a default one - Analyis of Issue
            if (!this.detailsView) {
                this.showDetailsView(GCCompanyPrincipleViews.AnalysisOfIssue);
            }
        }

        // select details view
        public showDetailsView(detailsView: string) {
            var ctx = this;

            ctx.detailsView = detailsView;
        }

        // get possible views
        public getPossibleDetailsViews() {
            var ctx = this;
            return GCCompanyPrincipleViews;
        }

        public getPillarId(): number {
            return this.companyPrinciple.principle.pillar.id;
        }
    }


    angular.module('Sustainalytics.GCCS').controller('GCCompanyPrincipleController',
        ['$scope', '$q', 'NumberUtilityService', GCCompanyPrincipleController]);
} 